package com.payment.web.controller.system;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.payment.common.annotation.Log;
import com.payment.common.base.AjaxResult;
import com.payment.common.enums.BusinessType;
import com.payment.common.page.TableDataInfo;
import com.payment.common.utils.ExcelUtil;
import com.payment.framework.web.base.BaseController;
import com.payment.system.domain.PypStore;
import com.payment.system.service.IPypStoreService;

/**
 * 碰一碰 信息操作处理
 * 
 * @author payment
 * @date 2020-01-09
 */
@Controller
@RequestMapping("/system/pypStore")
public class PypStoreController extends BaseController
{
    private String prefix = "system/pypStore";
	
	@Autowired
	private IPypStoreService pypStoreService;
	
	@RequiresPermissions("system:pypStore:view")
	@GetMapping()
	public String pypStore()
	{
	    return prefix + "/pypStore";
	}
	
	/**
	 * 查询碰一碰列表
	 */
	@RequiresPermissions("system:pypStore:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PypStore pypStore)
	{
		startPage();
        List<PypStore> list = pypStoreService.selectPypStoreList(pypStore);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出碰一碰列表
	 */
	@RequiresPermissions("system:pypStore:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PypStore pypStore)
    {
    	List<PypStore> list = pypStoreService.selectPypStoreList(pypStore);
        ExcelUtil<PypStore> util = new ExcelUtil<PypStore>(PypStore.class);
        return util.exportExcel(list, "pypStore");
    }
	
	/**
	 * 新增碰一碰
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存碰一碰
	 */
	@RequiresPermissions("system:pypStore:add")
	@Log(title = "碰一碰", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PypStore pypStore)
	{		
		return toAjax(pypStoreService.insertPypStore(pypStore));
	}

	/**
	 * 修改碰一碰
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		PypStore pypStore = pypStoreService.selectPypStoreById(id);
		mmap.put("pypStore", pypStore);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存碰一碰
	 */
	@RequiresPermissions("system:pypStore:edit")
	@Log(title = "碰一碰", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PypStore pypStore)
	{		
		return toAjax(pypStoreService.updatePypStore(pypStore));
	}
	
	/**
	 * 删除碰一碰
	 */
	@RequiresPermissions("system:pypStore:remove")
	@Log(title = "碰一碰", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(pypStoreService.deletePypStoreByIds(ids));
	}
	
}
